package com.yaojiaxun.logisticsPlatformSystem.mapper;

import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.yaojiaxun.logisticsPlatformSystem.entity.PersonInformation;
import org.apache.ibatis.annotations.*;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * @Auther: yjx_j
 * @Date: 2018/12/29 21:18
 * @Description:
 */
@Mapper
public interface PersonInformationMapper extends BaseMapper<PersonInformation> {
    @Select("select * from person_information where person_account = #{personAccount}")
    public PersonInformation findByPersonAccount(@Param("personAccount") String personAccount);

    @Select("select * from person_information where person_name = #{personName}")
    public List<PersonInformation> findByPersonName(@Param("personName") String personName);

    @Select("select * from person_information")
    public List<PersonInformation> findAllPerson();

    @Select("select * from person_information where person_id = #{personId}")
    public PersonInformation findByPersonId(@Param("personId") Long personId);

    @Update("update `person_information` set `person_account`=#{personAccount},`status`=#{status},`person_name`=#{personName},`sex`=#{sex},"+
    "`phone_number`=#{phoneNumber},`address`=#{address},`belonged_company`=#{belongedCompany},`id_card`=#{idCard},`bank_number`=#{bankNumber},`born`=#{born},`education`=#{education},"+
    "`political`=#{political},`property`=#{property},`character`=#{character},`work_date`=#{workDate} where `person_id`=#{personId}")
    public Integer updateByPersonId(@RequestParam("personInformation") PersonInformation personInformation);

    @Delete("delete from person_information where person_id=#{personId}")
    public Integer deleteByPersonId(@RequestParam("personId") Long personId);

    @Insert("insert into `person_information`(`person_id`,`create_time`,`update_time`,`person_account`,`status`,`person_name`,`sex`,`phone_number`,`address`,`belonged_company`,`id_card`,"+
            "`bank_number`,`born`,`education`,`political`,`property`,`character`,`work_date`,`password`) values"+
            "(#{personInformation.personId},#{personInformation.createTime},#{personInformation.updateTime},#{personInformation.personAccount},#{personInformation.status},#{personInformation.personName},#{personInformation.sex},#{personInformation.phoneNumber},#{personInformation.address},"+
            "#{personInformation.belongedCompany},#{personInformation.idCard},#{personInformation.bankNumber},#{personInformation.born},#{personInformation.education},#{personInformation.political},"+
            "#{personInformation.property},#{personInformation.character},#{personInformation.workDate},#{personInformation.password})")
    public Integer insertPerson(@Param("personInformation") PersonInformation personInformation);
}
